var WARN_TIME_OUT=1200;
var WINDOW_HEIGHT=$(window).height();
/**获得XML中的属性值*/
	function getXmlValue(xml,name){
		if(xml!=''&&name!=''){
			var obj;
			if (window.ActiveXObject)
		    {
		        obj =new ActiveXObject("Microsoft.XMLDOM");
		        obj.async="false";
		        obj.loadXML(xml);
		    }else{
		         var parser=new DOMParser();
		         obj =parser.parseFromString(xmlstring,"text/xml");
		      }
			return obj.getElementsByTagName(name)[0].firstChild.nodeValue;
		}else{
			return xml;
		}
		
	}
function setTagAndValue(form,tag,value){
	if($("#"+form).find("#"+tag).length==0){
		var t='<input type="hidden" id="'+tag+'" name="'+tag+'" value="">';
		$("#"+form).append(t);   
	}     
	$("#"+form).find("#"+tag).val(value);   
}  
function changeFk1(n){
	changeFk(n);
}
/**全选*/
function changeFk(n){
	var s = "";
	if(n!=null&&n!=''){
		s=n;
	}
	$("#checkAll"+s).click(function(){	    
	 if($("#checkAll"+s).prop("checked")){
		   $("input[name='checkId"+s+"']").each(function(){
			   $(this).prop("checked",true);
			   if(globalCheckValue != null){
				   isCheckValue(this.id);
			   }
			   
		   }); 
	 }else{
		 $("input[name='checkId"+s+"']").each(function(){
			   $(this).prop("checked",false); 
			   if(globalCheckValue != null){
				   isCheckValue(this.id);
			   }
		   });
	 }
 });	
 //$(".fsplit").attr("src",ctp+"/web/fno/images/split.png");
 //$("tr:odd").css("background-color", "#EEEFE0");  //隔行颜色
 //$(".ntable").delegate("tr","hover",function(){
//	 $(this).toggleClass("fBackClass");
 //});
}

/**
 * 统一获取勾选id集合 eg:1,2,3
 * n:第几个选择框 selfName:自定义input属性
 * @returns {String}
 */
function getCheckIds(n,selfName) {
	var str = '';
	if(globalCheckValue != null){
		if(selfName == null || selfName == ""){
			str = globalCheckValue[0][1].join(",");
		}else{
			for(var i = 1; i < globalCheckValue.length; i++){
				if(globalCheckValue[i][0] == selfName){
					str = globalCheckValue[i][1].join(",");
				}
			}
		}
	}else{
		var s = '';
		if(null != n && "" != n){
			s = n;
		}
		$("input[name=checkId"+s+"]").each(function() {
			if ($(this).prop("checked")) {
				if(null != selfName && "" != selfName){
					str += $(this).attr(selfName) + ",";
				}else{
					str += $(this).val() + ",";
				}
			}
		});
		if(str.length > 1){
			str = str.substring(0, str.length - 1);
		}
	}
	return str;
}




/**
 * 单选行获取隐藏在radio中的值
 * @param selfName
 * @returns {String}
 */
function getRadioTdValueByName(selfName) {
	var str = '';
	$("input[name=checkId]").each(function() {
		if ($(this).prop("checked")) {
			if(null != selfName && "" != selfName){
				str += $(this).attr(selfName);
			}else{
				str += $(this).val();
			}
		}
	});
	return str;
}



/*
function mediaAlert(){ 
	var msg = "提示111:"; 
	var content = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
	mediaAlertx(1,msg,content);
}*/
function mediaAlert(msg,content){ 
	msg=msg==null?"":msg; 
	mediaAlertx(1,msg,content); 
}
function mediaAlertx(v,msg,content){
	var a='<div id="mediaAlertx" style="zIndex:100000;"></div>';
	if($("body").find("#mediaAlertx").length==0){
		$("body").append(a);  
	}
   if(msg==''||msg==null){
     msg ="提示信息";
   }
   var line = 0;
  if(content!=''&&content!=null&&content.length>24){
	  line = Math.ceil(content.length / 24) - 2;
  }
 //window.scrollTo(0,0);
 var b = document.getElementsByTagName('body')[0];
 var h = document.getElementsByTagName('html')[0];
 var boht = document.getElementById('mediaAlertx');    
 boht.innerHTML = '';
 b.style.height='auto';
 b.style.overflow='auto';
 h.style.height='auto'; 
 if(v == 1){   
  b.style.height='100%';
  b.style.overflow='hidden';
  h.style.height='100%';  
  boht.innerHTML = '<div id="mediabg"></div><div id="mediaInfo"><div id="alertCenter"><strong>'+msg+'</strong><p>'+content+'</p><span><input type=\"button\" class="BtnWhite btnfont" onclick="mediaAlertx(0);" value=\"确定\"/></span></div></div>';
  $("#mediaInfo").css("height",(line*22+120)+"px");  
  $("#mediaInfo").css("marginTop",-(line*22+120)/2+"px");
 
 
  
 }
}  

function mediaAlerts(msg,contents){
	mediaAlertxx(1,msg,contents);
}

function mediaAlertxx(v,msg,contents){  
	var a='<span id="mediaAlertx" style="zIndex:100000;"></span>';
	if($("body").find("#mediaAlertx").length==0){
		$("body").append(a);  
	}
   if(msg==''||msg==null){
     msg ="提示信息";
   }
   var line=0;
   var content = "";
  if(contents!=null){
	  for(var i=0;i<contents.length;i++){
		  var temp=contents[i];
		  line++;
		  if(temp!=''&&temp!=null&&temp.length>24){
			  temp =temp.substring(0,24)+"</br>"+temp.substring(24,48);
			  line++;
		   } 
		  content+=(i+1)+" :"+temp+"</br>"; 
	  }
  } 
 //window.scrollTo(0,0);
 var b = document.getElementsByTagName('body')[0];
 var h = document.getElementsByTagName('html')[0];
 var boht = document.getElementById('mediaAlertx');    
 boht.innerHTML = '';
 b.style.height='auto';
 b.style.overflow='auto';
 h.style.height='auto';  
 if(v == 1){   
 // b.style.height='100%'; 
  b.style.overflow='hidden';
 // h.style.height='100%';  
  boht.innerHTML = '<div id="mediabg"></div><div id="mediaInfo"><div id="alertCenter"><strong>'+msg+'</strong><p>'+content+'</p><span><input type=\"button\" class="BtnWhite btnfont" onclick="mediaAlertx(0);" value=\"确定\"/></span></div></div>';
  //最后设置高度
  $("#mediaInfo").css("height",(line*18+95)+"px");  
  $("#mediaInfo").css("marginTop",-(line*21+70)/2+"px");  
  $("#alertCenter p").css("text-align","left");
 }
} 
function getFullDate(date){
	var now = "";
	now = date.getFullYear()+"-";
	now = now + (date.getMonth()+1)+"-";
	now = now + date.getDate()+" ";
	return now;
}
function getFullWeek(date){
	var i = new Date().getDay();
	if(i=='1'){
		return "星期一";
	}else if(i=='2'){
		return "星期二";
	}else if(i=='3'){
		return "星期三";
	}else if(i=='4'){
		return "星期四";
	}else if(i=='5'){
		return "星期五";
	}else if(i=='6'){
		return "星期六";
	}else if(i=='7'){
		return "星期七";
	}
}
function getFullTime(date){
	var now = "";	
	now = now + date.getHours()+":";
	now = now + date.getMinutes()+":";
	now = now + date.getSeconds()+"";
	return now;
}

/**
 * n 为页面所存在的分页个数
 * **/
function writePage(pageJson,n){
	/*if(pageJson.rc == 0){
		return "";
	}
	var s = '';
	if(null != n && "" != n){
		s = n;
	}
	
	var htmlStr="";
	htmlStr += "<label><input type=\"button\" style=\"height:25px;\" onclick=\"searchDataGo"+s+"()\" class=\"go\" value=\"跳转\" /></label>";
	htmlStr += "<label><input type=\"text\" id=\"go"+s+"\" name=\"go"+s+"\"  value=\"\" style=\"width:32px;\"></label>";
	if(pageJson.curr != pageJson.pc){
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+pageJson.pc+"')\">尾页</a>";
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)+1)+"')\">下页</a>   ";		
	}
	if(pageJson.curr != 1){
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)-1)+"')\">上页</a>   ";
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('1')\">首页</a>   ";
	}
	htmlStr+="<span>共<strong>["+ pageJson.cr +"/"+pageJson.rc +"]</strong>条</span>";
	htmlStr+="<span>第<strong>"+pageJson.curr+"/"+pageJson.pc+"</strong>页</span>";
	htmlStr += "<a class=\"update\" href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+pageJson.curr+"')\" title=\"刷新\"></a>";
	return htmlStr;*/
	if(pageJson.rc == 0){
		return "";
	}
	var s = '';
	if(null != n && "" != n){
		s = n;
	}
	
	var htmlStr="";
	htmlStr+="<div class=\"paging fixed\" id=\"mPage\">";
	htmlStr+="<div class=\"box\">";
	htmlStr+="<div class=\"left\">";
	htmlStr+="<label>当前第</label>";
		htmlStr+="<span class=\"a\" id=\"current\">"+pageJson.curr+"</span>";
		htmlStr+="<div class=\"sub\">";
		htmlStr+="<input type=\"text\" value=\"3\">";
		htmlStr+="<div class=\"btn\">跳转</div>";
		htmlStr+="</div>";
			htmlStr+="<label>页&nbsp;&nbsp;共</label><span class=\"a\" id=\"count\">"+pageJson.pc+"</span><span>页</span><span class=\"italic\">&nbsp;&nbsp;(总</span><span class=\"a italic\" id=\"rowCount\">"+pageJson.rc+"</span><span class=\"italic\">条记录)</span>";
			htmlStr+="</div>";
				htmlStr+="<div class=\"right\">";
				if(pageJson.curr != 1){
				htmlStr+="<div class=\"btn fp\" onclick=\"searchData"+s+"('1')\">首页</div>";
	htmlStr+="<div class=\"btn pp\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)-1)+"')\">上页</div>";
				}
	if(pageJson.curr != pageJson.pc){
	htmlStr+="<div class=\"btn np\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)+1)+"')\">下页</div>";
	htmlStr+="<div class=\"btn lp\" onclick=\"searchData"+s+"('"+pageJson.pc+"')\">尾页</div>";
	}
	htmlStr+="</div>";
		htmlStr+="<input id=\"qryInfo\" type=\"hidden\">";
		htmlStr+="<div class=\"clear\"></div>";
		htmlStr+="</div>";
			htmlStr+="</div>";

return htmlStr;
}


/**
 * n 为页面所存在的分页个数
 * **/
function writePage2(pageJson,n){
	/*if(pageJson.rc == 0){
		return "";
	}
	var s = '';
	if(null != n && "" != n){
		s = n;
	}
	
	var htmlStr="";
	htmlStr += "<label><input type=\"button\" style=\"height:25px;\" onclick=\"searchDataGo"+s+"()\" class=\"go\" value=\"跳转\" /></label>";
	htmlStr += "<label><input type=\"text\" id=\"go"+s+"\" name=\"go"+s+"\"  value=\"\" style=\"width:32px;\"></label>";
	if(pageJson.curr != pageJson.pc){
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+pageJson.pc+"')\">尾页</a>";
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)+1)+"')\">下页</a>   ";		
	}
	if(pageJson.curr != 1){
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)-1)+"')\">上页</a>   ";
		htmlStr += "<a href=\"javascript:void(0)\" onclick=\"searchData"+s+"('1')\">首页</a>   ";
	}
	htmlStr+="<span>共<strong>["+ pageJson.cr +"/"+pageJson.rc +"]</strong>条</span>";
	htmlStr+="<span>第<strong>"+pageJson.curr+"/"+pageJson.pc+"</strong>页</span>";
	htmlStr += "<a class=\"update\" href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+pageJson.curr+"')\" title=\"刷新\"></a>";
	return htmlStr;*/
	if(pageJson.rc == 0){
		return "";
	}
	var s = '';
	if(null != n && "" != n){
		s = n;
	}
	
	var htmlStr="";
	htmlStr+="<div class=\"paging fixed\" id=\"mPage\">";
	htmlStr+="<div class=\"box\">";
	htmlStr+="<div class=\"left\">";
	htmlStr+="<label>当前第</label>";
		htmlStr+="<span class=\"a\" id=\"current\">"+pageJson.curr+"</span>";
		htmlStr+="<div class=\"sub\">";
		htmlStr+="<input type=\"text\" value=\"3\">";
		htmlStr+="<div class=\"btn\">跳转</div>";
		htmlStr+="</div>";
			htmlStr+="<label>页&nbsp;&nbsp;共</label><span class=\"a\" id=\"count\">"+pageJson.pc+"</span><span>页</span><span class=\"italic\">&nbsp;&nbsp;(总</span><span class=\"a italic\" id=\"rowCount\">"+pageJson.rc+"</span><span class=\"italic\">条记录)</span>";
			htmlStr+="</div>";
				htmlStr+="<div class=\"right\">";
				if(pageJson.curr != 1){
	htmlStr+="<div class=\"btn pp\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)-1)+"')\">上页</div>";
				}
	if(pageJson.curr != pageJson.pc){
	htmlStr+="<div class=\"btn np\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)+1)+"')\">下页</div>";
	}
	htmlStr+="</div>";
		htmlStr+="<input id=\"qryInfo\" type=\"hidden\">";
		htmlStr+="<div class=\"clear\"></div>";
		htmlStr+="</div>";
			htmlStr+="</div>";

return htmlStr;
}


/** 无数据时显示*/
function writePage1(pageJson,n){	
/*	var htmlStr="";	
	htmlStr+="<span>共<strong>["+0+"/"+0+"]</strong>条</span>";
	htmlStr+="<span>第<strong>"+0+"/"+0+"</strong>页</span>";
	htmlStr += "<a class=\"update\" href=\"javascript:void(0)\" onclick=\"location.reload()\" title=\"刷新\"></a>";
	return htmlStr;*/
	
	
	var htmlStr="";
	htmlStr+="<div class=\"paging fixed\" id=\"mPage\">";
	htmlStr+="<div class=\"box\">";
	htmlStr+="<div class=\"left\">";
	htmlStr+="<label>当前第</label>";
		htmlStr+="<span class=\"a\" id=\"current\">"+0+"</span>";
		htmlStr+="<div class=\"sub\">";
		htmlStr+="<input type=\"text\" value=\"3\">";
		htmlStr+="<div class=\"btn\">跳转</div>";
		htmlStr+="</div>";
			htmlStr+="<label>页&nbsp;&nbsp;共</label><span class=\"a\" id=\"count\">"+0+"</span><span>页</span><span class=\"italic\">&nbsp;&nbsp;(总</span><span class=\"a italic\" id=\"rowCount\">"+0+"</span><span class=\"italic\">条记录)</span>";
			htmlStr+="</div>";
				htmlStr+="<div class=\"right\">";
				
	htmlStr+="</div>";
		htmlStr+="<input id=\"qryInfo\" type=\"hidden\">";
		htmlStr+="<div class=\"clear\"></div>";
		htmlStr+="</div>";
			htmlStr+="</div>";

return htmlStr;
}

/**
 * n 为页面所存在的分页个数
 * **/
function writePicPage(pageJson,n){
	if(pageJson.rc == 0){
		return "";
	}
	var s = '';
	if(null != n && "" != n){
		s = n;
	}
	
	var htmlStr="";
	htmlStr+="<span>共<strong>["+ pageJson.cr +"/"+pageJson.rc +"]</strong>条</span>";
	htmlStr+="<span>第<strong>"+pageJson.curr+"/"+pageJson.pc+"</strong>页</span>";
	if(pageJson.curr != pageJson.pc){
		htmlStr += "<a class=\"lastpage\" href=\"javascript:void(0)\" title=\"尾页\" onclick=\"searchData"+s+"('"+pageJson.pc+"')\">尾页</a>";
		htmlStr += "<a class=\"nextpage\" href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)+1)+"')\">下页</a>   ";		
	}
	if(pageJson.curr != 1){
		htmlStr += "<a class=\"prevpage\" href=\"javascript:void(0)\" onclick=\"searchData"+s+"('"+(parseInt(pageJson.curr,10)-1)+"')\">上页</a>   ";
		htmlStr += "<a class=\"frontpage\" href=\"javascript:void(0)\" onclick=\"searchData"+s+"('1')\">首页</a>   ";
	}
	return htmlStr;
}

/**
 * 特殊字符转换
 * @param   {String}    字符串
 * @return  {String}    转换后的字符串
 */
function replaceHTML(str){
	if(typeof(str)=="undefined")str="";
	if(str==null)str="";
	str = str.replace(/\"/g,"&quot;");
	str = str.replace(/\</g,"&lt;");
	str = str.replace(/\>/g,"&gt;");
	return str;
}
/**
 * 时间格式化
 * @param now
 * @returns {String}
 */
function formatDate(now){
	var d;
	if(null != now && "" != now){
		d = new Date(now);
	}else{
		d = new Date();
	}
    var year = d.getFullYear();     
    var month = (d.getMonth()+1)>9?(d.getMonth()+1):"0"+(d.getMonth()+1);     
    var date = d.getDate()>9?d.getDate():"0"+d.getDate();     
    var hour = d.getHours()>9?d.getHours():"0"+d.getHours();  
    var minute = d.getMinutes()>9?d.getMinutes():"0"+d.getMinutes();     
    var second = d.getSeconds()>9?d.getSeconds():"0"+d.getSeconds();     
    return year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second;     
} 

function formatDateHMS(d){	
    var year = d.getFullYear();
    var month = (d.getMonth()+1)>9?(d.getMonth()+1):"0"+(d.getMonth()+1);     
    var date = d.getDate()>9?d.getDate():"0"+d.getDate();    
    return year+"-"+month+"-"+date;
} 

/** 如果太长串，截取，如num=8 abcdefgh--->abcdef..  2014-12-8 chs add */
function writeStringByNum(s,num){	
	if(s!=null){
		var len = getStrLen(s);
		if(len>num){
			  var reg = /[\u4e00-\u9fa5]/g;    
			    var slice = s.substring(0,num),  
			   realen = num - ( ~~( slice.match(reg) && slice.match(reg).length ) );  
			  return slice.substring(0,realen-2)+".."; 
			//return s.substring(0,num-2)+"..";
		}
		return s;
	}
	return "";
} 
function getStrLen(s) {  
   return s.replace(/[^\x00-\xff]/g, '__').length; 
} 

/**空判断和去空格 2014-12-08 chs add*/
function stringTrim(s){
	if(typeof(s)=='undefined'||s==null||s==''||s=='undefined')return "";
	return  s.replace( /^\s*/, "").replace( /\s*$/, "");
}

/**格式化大小 KB MB G**/
function sizeFormate(size) {
	if(typeof(size)=='undefined' || size == 'undefined' || null == size || size=='' || size=='NaN') return '';
	try{
		size = parseInt(size,10);
	}catch(e){}
	if (size < 1024 * 1024) {
		return (size / (1024.0)).toFixed(2) + "KB";
	} else if (size < 1024 * 1024 * 1024) {
		return (size / (1024 * 1024.0)).toFixed(2) + "MB";
	} else {
		return (size / (1024 * 1024 * 1024.0)).toFixed(2) + "GB";
	}
}

function formateTime(time) {
	if(typeof(time)=='undefined' || null == time || time == 'undefined' || "" == time){
		return '';
	}
	try{
		size = parseInt(time,10);
	}catch(e){}
	if (null!= time &&""!= time) {
        if (time >60&& time <60*60) {
            time = parseInt(time /60.0) +"分钟"+ parseInt((parseFloat(time /60.0) -
            parseInt(time /60.0)) *60) +"秒"; 
        }else if (time >=60*60&& time <60*60*24) {
            time = parseInt(time /3600.0) +"小时"+ parseInt((parseFloat(time /3600.0) -
            parseInt(time /3600.0)) *60) +"分钟"+
            parseInt((parseFloat((parseFloat(time /3600.0) - parseInt(time /3600.0)) *60) -
            parseInt((parseFloat(time /3600.0) - parseInt(time /3600.0)) *60)) *60) +"秒";
        }else {
            time = parseInt(time) +"秒";
        }
    }else{
        time = "0 时 0 分0 秒";
    }
    return time;
}

//修复ie8对trim不支持 niujs 20150122
String.prototype.trim = function () {
    return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
};

function openWin(form,url,data){
	if(typeof(data)=="undefined")data=null;
	if($("#"+form).length==0){
		var html = "<div id=\""+form+"\" name=\""+form+"\" class=\""+form+"\">"; 
		html+="<div class=\"maskDiv\" style=\"display:none;\"></div>";
		html+="<div class=\"popDiv tableList_pop\" style=\"display:none;\">";
		html+="<div class=\"popMain\">";
		html+="<div class=\"popClose\"><a href=\"javascript:void(0)\" onclick=\"closeWin('"+form+"');\">关闭</a></div>";
		html+="<div class=\"contentDiv\"></div>";
		html+="</div>";
		html+="</div>";
		html+="</div>";
		$("body").append(html);
		$("#"+form).find(".contentDiv").load(url,data,function(){
			var popW=$(".tableList_pop").outerWidth();
			var popH=$(".tableList_pop").outerHeight();
			$(".tableList_pop").css("margin-top",-popH);
			$(".tableList_pop").css("margin-left",-popW/2);
			$("#"+form).find(".maskDiv").show(); 
			$("#"+form).find(".tableList_pop").show();
		});
	}
}

function openIframe(form,url){
	var html = "<div id=\""+form+"\" name=\""+form+"\" class=\""+form+"\">"; 
	html+="<div class=\"maskDiv\" style=\"display:none;\"></div>";
	html+="<div class=\"popDiv tableList_pop\" style=\"display:none;\">";
	html+="<div class=\"popMain\">";
	html+="<div class=\"popClose\"><a href=\"javascript:void(0)\" onclick=\"closeWin('"+form+"');\">关闭</a></div>";
	html+="<div class=\"contentDiv\">";
	html+="<iframe style=\"height:"+($(window).height()-92)+"px;\" id='"+form+"Iframe' name='"+form+"Iframe' src='"+url+"' frameborder='0' width='100%' height='100%' scrolling='auto'></iframe>";
	html+="</div>";
	html+="</div>";
	html+="</div>";
	html+="</div>";
	$("body").append(html);
	var popW=$(".tableList_pop").outerWidth();
	var popH=$(".tableList_pop").outerHeight();
	$(".tableList_pop").css("margin-top",-popH/2);
	$(".tableList_pop").css("margin-left",-popW/2);
	$("#"+form).find(".maskDiv").show(); 
	$("#"+form).find(".tableList_pop").show();
}

function closeWin(form){
	$("#"+form+" .popDiv").hide();
	$("#"+form+" .maskDiv").hide();
	$("#"+form).remove();
}
function openDiv(form,div){
	var html = '<div id="prox" class="popDiv tableList_pop" style="margin-top: -226.5px; margin-left: -440px;"><div class="popMain"><div class="popClose"><a onclick="closeWin(\'prox\');" href="javascript:void(0)">关闭</a></div><div class="contentDiv">'+div+'</div></div></div>';
	$("body").append(html);
	var popW=$(".tableList_pop").outerWidth();
	var popH=$(".tableList_pop").outerHeight();
	$(".tableList_pop").css("margin-top",-popH/2);
	$(".tableList_pop").css("margin-left",-popW/2);
	$("#"+form).find(".maskDiv").show(); 
	$("#"+form).find(".tableList_pop").show();
}

/**
 * 弹出普通提示层
 * 
 * @param msg
 *            提示内容
 * @param titie
 *            提示标题
 */
function showAlert(mes,func) {
	 $.messager.alert('提示信息',mes,'info',function(){func();});
	 //换样式
	// BtnWhite btnfont
	 $(".l-btn l-btn-small").addClass("BtnWhite");  
	 $(".l-btn l-btn-small").addClass("btnfont");  
}

/**
 * 弹出错误提示层
 * 
 * @param msg
 *            提示内容
 * @param titie
 *            提示标题
 */
function showError(msg, fuc) {
	$.messager.alert('提示',msg,'error',function(){func();});
}

/**
 * 弹出确认提示层
 * 
 * @param titie
 *            提示标题
 * @param msg
 *            提示内容
 * @param fuc
 *            点击确定后执行的函数
 */
function showConfirm(title,mes,func){
	$.messager.confirm(title, mes, function(r){
	if (r){
	func();
	}
	});
}

/**打印对象*/
function alertObjects(myObject) {  
	  var s = "";  
	  for (var property in myObject) {  
	   s = s + "\n "+property +": " + myObject[property] ;  
	  }  
	  alert(s);  
	}  

//解决div触发事件后，checkbox无效问题 add by cbin 2013-12-25
function changeCheckBox(){
	//注：火狐和IE获取event的方法不一样。
	var ev = window.event || arguments.callee.caller.arguments[0];
	ev.cancelBubble = true;
}

function getAlerts(maxlen,ss,type){
	var ww= $(window).width(); 
	var wh= $(window).height();	
	layer.alert(ss, type);	
	var obj = $(".xubox_layer");
	obj.css("top",(wh-obj.height())/2);
	var nlen = 400;
	if(maxlen>=20){
		nlen=(maxlen-20)*15+400;
	}
	obj.css("width",nlen+"px");
	var ol = -nlen/2;
	obj.css("margin-left",ol+"px");
	$(".xubox_border").css("width",(nlen+12)+"px");
}
function jalerts(s){
	var ww= $(window).width(); 
	var wh= $(window).height(); 
	var maxHeight = wh-135;
	var maxCot = parseInt((maxHeight-50)/25);	
	var maxlen = 0;
	var ss = "温馨提示<br>";
	if(s!= null&&s.length>0){
		for(var i = 0;i<s.length;i++){
			ss+=(i+1)+"、"+s[i]+"<br>";
			if(i>=maxCot){
				ss+="更多......";
				break;
			}
			if(s[i].length>maxlen){
				maxlen = s[i].length;
			}
		}
	}
	getAlerts(maxlen,ss,8);
}

function jalert(msg){
	getAlerts(1,msg,8);
}
function jalert9(msg){
	getAlerts(1,msg,9);
}
function jconfirm(fun,msg){
	$.layer({
	    shade: [0],
	    area: ['auto','auto'],
	    dialog: {
	        msg: "温馨提醒："+msg,
	        btns: 2,                    
	        type: 4,
	        btn: ['确认','取消'],
	        yes: function(i){
	        	eval(fun);
	        	layer.close(i);
	        }, no: function(){
	        }
	    }
	});
}



function jconfirmClient(fun,msg){
	$.layer({
	    shade: [0],
	    area: ['auto','auto'],
	    dialog: {
	        msg: "温馨提醒："+msg,
	        btns: 2,                    
	        type: 4,
	        btn: ['确认','取消'],
	        yes: function(i){
	        	layer.close(i);
	        }, no: function(){
	        	eval(fun);
	        }
	    }
	});
}



function jconfirm1(fun,msg){
	//用来显示信息后跳转页面
	$.layer({
		closeBtn: false, //不显示关闭按钮
	    shade: [0],
	    area: ['auto','auto'],
	    dialog: {
	        msg: "温馨提醒："+msg,
	        btns: 1,                    
	        type: 9,
	        btn: ['确认'],
	        yes: function(i){
	        	eval(fun);
	        	layer.close(i);
	        }
	    }
	});
}

/*含有遮罩层的弹出框*/
function jconfirm2(fun,msg){
	//用来显示信息后跳转页面
	$.layer({
		closeBtn: false, //不显示关闭按钮
	    shade : [0.5 , '#000' , true],
	    shadeClose : false,
	    area: ['auto','auto'],
	    dialog: {
	        msg: "温馨提醒："+msg,
	        btns: 1,                    
	        type: 8,
	        btn: ['确认'],
	        yes: function(i){
	        	eval(fun);
	        	layer.close(i);
	        }
	    }
	});
}

/*弹出框 */
function dialogWin(iwidth,iheight,src,title){
	/*var hh = $(window).height();
	var top = 50;
	var width = iwidth;
	var height = iheight;
	var marginLeft=-iwidth/2;
	var itop = 0;*/
	var html='<div class="xubox_layer111" style="position:fixed;top:150px;height:100px;width:600px;margin:0 auto; left:0;right:0;bottom:0; z-index:1000;"><div class="is-loding"></div></div><div class="xubox_layer111 bg-shadow" style="position:fixed;top:0px;left:0px;right:0;bottom:0; z-index:999;"></div><div class="xubox_layer111" style="position:fixed;top:0px;left:0;right:0;bottom:0; z-index:9999;"><iframe class="ifs" name="xubox_iframe1" id="xubox_iframe1" src="'+src+'" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" allowtransparency="true" onload="this.className=\'xubox_iframe\'"></iframe></div>';

	
//	var html='<div class="xubox_layer111 bg-shadow" style="position: fixed; top: 0;right: 0;bottom: 0;left: 0;z-index:1;"></div><div class="xubox_layer111" style="padding-bottom:20px;  position: fixed; top: 0;right: 0;bottom: 0;left: 0; z-index: 20; overflow: auto;"> <div style=" box-shadow: 0 0 80px 0 rgba(0,0,0,.4);position:relative;left: 50%; margin-top: 13vh; width: '+width+'px; height: '+height+'px; margin-left: '+marginLeft+'px;" times="1" showtime="0" type="iframe"><iframe name="xubox_iframe1" id="xubox_iframe1" src="'+src+'" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" allowtransparency="true" onload="this.className=\'xubox_iframe\'"></iframe><a class="xulayer_png32" style="display:block; position:absolute;z-index:9999; right:20px; top:15px; height:20px;width:20px" href="javascript:;" onclick="closeDialogWin();"></a></div></div>';
//    var html='<div class="xubox_layer111" style="position: fixed; top: 0;right: 0;bottom: 0;left: 0; z-index: 10; overflow: auto;"> <div style=" box-shadow: 0 0 80px 0 rgba(0,0,0,.4);opacity: 1;filter: alpha(opacity=100); position:relative;left: 50%; margin-top: 20vh; width: '+width+'px; height: '+height+'px; margin-left: '+marginLeft+'px;" times="1" showtime="0" type="iframe"><iframe name="xubox_iframe1" id="xubox_iframe1" src="'+src+'" frameborder="0" scrolling="auto" style="width: 100%; height: 100%;" allowtransparency="true" onload="this.className=\'xubox_iframe\'"></iframe><a class="xulayer_png32" style="display:block; position:absolute;z-index:9999; right:20px; top:15px; height:20px;width:20px" href="javascript:;" onclick="closeDialogWin();"></a></div></div>';
//	var html='<div class="xubox_layer111" id="xubox_layer1" style="left: 50%; top: '+top+'px; width: '+width+'px; height: '+200+'px; margin-left: '+marginLeft+'px; z-index: 198910150000;" times="1" showtime="0" type="iframe"><div class="xubox_main" style="z-index: 198910150000; background-color: rgb(255, 255, 255);"><iframe name="xubox_iframe1" class="xubox_iframe" id="xubox_iframe1" src="'+src+'" frameborder="0" scrolling="auto" style="top: '+itop+'px; width: '+width+'px; height: '+iheight+'px;" allowtransparency="true" onload="this.className=\'xubox_iframe\'"></iframe><div class="xubox_title" style="cursor: move;" move="ok"><em>'+title+'</em></div><span class="xubox_setwin"><a class="xubox_close xulayer_png32 xubox_close1" href="javascript:;" onclick="closeDialogWin();"></a></span><span class="xubox_botton"></span></div></div>';
	$("body").append(html);
	//window.top.document.querySelector('#shadow').style.display = "block";
	document.body.style.overflow = "hidden";  //禁用body滚动条
	
}
function closeDialogWin(){
	if(navigator.userAgent.indexOf("MSIE")>0 || navigator.userAgent.indexOf("Trident")>0){
		$("#xubox_iframe1").remove();
		CollectGarbage();
    }
	$(".xubox_layer111").remove();
	//window.top.document.querySelector('#shadow').style.display = "none";
	document.body.style.overflow = "auto";  //恢复body滚动条
}



/* 密码验证1
 * 密码是否含有“小写字母”、“大写字母”、“数字”、“特殊符号”中的任意三种 长度为6-20之间
 * */
function testPass(str){
    var rC = {
        lW:'[a-z]',
        uW:'[A-Z]',
        nW:'[0-9]',
        sW:'[\\u0020-\\u002F\\u003A-\\u0040\\u005B-\\u0060\\u007B-\\u007E]'
    };
    function Reg(str, rStr){
        var reg = new RegExp(rStr);
        if(reg.test(str)) return true;
        else return false;
    }
    if(str.length < 6||str.length>20){
        //  document.title = '密码长度为6到20之间';
        return false;
    }else{
        var tR = {
            l:Reg(str, rC.lW),
            u:Reg(str, rC.uW),
            n:Reg(str, rC.nW),
            s:Reg(str, rC.sW)
        };
        if((tR.l && tR.u && tR.n) || (tR.l && tR.u && tR.s) || (tR.s && tR.u && tR.n) || (tR.s && tR.l && tR.n)){
         //   document.title = '密码符合要求';
            return true;
        }else{
          //  document.title = '您的密码必须含有“小写字母”、“大写字母”、“数字”、“特殊符号”中的任意三种';
            return false;
        }
    }
}

/* 密码验证2
 * 密码不为重复的或连续的6位数字,
 * */
function checkPassword(pwd){
    // 长度为6的数字
   /* var r= '/^\d{6}$/';
    var reg = new RegExp(r);
    if(!reg.test(pwd)){
        return false;
    }*/
    // 全部重复
    var repeat = true;
    // 连续字符
    var series = true;
 
    var len = pwd.length;
    var first = pwd.charAt(0);
    for(var i=1;i<len;i++){
        repeat = repeat && pwd.charAt(i) == first;
        series = series && pwd.charCodeAt(i) == pwd.charCodeAt(i-1) + 1;
    }
    return (repeat || series);
}

//求字符串长度
function len(s) {
 	var l = 0;
 	var a = s.split("");
 	for (var i=0;i<a.length;i++) {
 	 	if (a[i].charCodeAt(0)<299) {
 		 	 l++;
 		 } else {
  			 l+=2;
  		}
	 }
 	return l;
}
/*
 * 验证数字*/
function shuzi(str){
	var s = /^[0-9]*$/;
	return s.test(str);
}
/*
 * 获取tree层级文件名路径
 * */
function getTreeFilePath(treeObj){
	if(treeObj==null)return "";
	var filename = treeObj.ROLE_NAME;
	var pNode = treeObj.getParentNode();
	if(pNode!=null){
	   filename = getTreeFilePath(pNode) +">"+ filename;
	}
	return filename;
}

//注册键盘事件
document.onkeydown = function(e) {
  //捕捉回车事件
  var ev = (typeof event!= 'undefined') ? window.event : e;
  if(ev.keyCode == 13) {
      return false;//禁用回车事件
  }
}

//禁止事件冒泡
function stopBubble(e) {  
    var e = e ? e : window.event;  
    if (window.event) { // IE  
        e.cancelBubble = true;   
    } else { // FF  
        //e.preventDefault();   
        e.stopPropagation();   
    }   
} 

//js生成uuid
function uuid() {
    return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
        var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
        return v.toString(16);
    });
}

//tab样式切换
function tabStyleTurn(classParm) {
    $(classParm).click(function () {
        $(classParm).removeClass('active');
        $(this).addClass('active');
    })
}

//生成年月日时分秒毫秒的时间流水
function getTimeBusiflow(){
	var d = new Date();
	var year = d.getFullYear() + "";
	var month = d.getMonth() + 1;
	if(month < 10) month = "0" + month;
	var day = d.getDate();
	if(day < 10) day = "0" + day;
	var hour = d.getHours();
	if(hour < 10) hour = "0" + hour;
	var min = d.getMinutes();
	if(min < 10) min = "0" + min;
	var sec = d.getSeconds();
	if(sec < 10) sec = "0" + sec;
	var mil = d.getMilliseconds();
	if(mil < 10) mil = "00" + mil;
	else if(mil < 100 && mil >= 10) mil = "0" + mil;
	return year.substring(2,4) + month + day + hour + min + sec + mil;
}

function gotoBack(){
	history.go(-1);
}

var gettype = Object.prototype.toString;
var utility = {
	isObj : function(o) {
		return gettype.call(o) == "[object Object]";
	},
	isArray : function(o) {
		return gettype.call(o) == "[object Array]";
	},
	isNULL : function(o) {
		return gettype.call(o) == "[object Null]";
	},
	isDocument : function() {
		return gettype.call(o) == "[object Document]";
	}
};

//用于固定表投滚动效果
function bowerScroll(){
	if(navigator.userAgent.indexOf('Chrome') > 0){
		$('.smart-cell_tbhead').css('width', $('.smart-cell_tbbody').width()-10 + 'px');
	}else{
		$('.smart-cell_tbhead').css('width', $('.smart-cell_tbbody').width()-17 + 'px');
	}
}

//js时间格式化
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}